#include <g-bios.h>
#include <flash/flash.h>
#include <flash/part.h>
#include <arch/mem.h>
#include <core/cmd.h>


static __INIT__ int InitSysCrit(void)
{
	int nf = 1;
	INIT_FUNC_PTR *ppfInitCall = g_pfInitCallBegin;
	const char* pFuncName;

	while (ppfInitCall < g_pfInitCallEnd)
	{
		int ret;

		pFuncName = GuGetFuncName(*ppfInitCall);

		printf("%2d. [", nf);
		if(pFuncName)
			printf("%s() @ ", pFuncName);
		printf("0x%08x]\n", *ppfInitCall);

		ret = (*ppfInitCall)();
		if (ret < 0)
			puts("Failed!\n");
		else
			puts("OK!\n");

		ppfInitCall++;
		nf++;
	}

	return 0;
}


int main(int argc, char *argv[])
{
	char szMsg[MAX_ARGV_SIZE];


	InitSysCrit();

	AutoBootGBios();

	CreatetCmdQueue();

	while (GetMessage(szMsg))
	{
		int   argc;
		char *argv[MAX_APP_ARG];

		argc = TranslateMessage(szMsg, argv);
		// if argc < 0

		DispatchMessage(argc, argv);
	}

	return 0;
}

